Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependent type checking fallback #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxkurze1
Copy link

Type checking for dependent Koika functions

The default type checker only tries to construct the checked term by using vm_compute. However, when a Koika function depends on some variable, say s, this check will get stuck on a term like forall s, ... EqDec.ec_dec s s .... This equality is rather computed than proven, but for this computation it is necessary to know the exact value of s.

To circumvent this problem (and it is really more a workaround than a solution), I built a tactic, that carefully computes the type leaving eq_dec occurrences untouched. These occurrences are then (if possible) rewritten with a proof.

This workaround is incorporated into the normal type checking algorithm as a fallback, in other words, the type checker will first try to construct the term using vm_compute (which should be faster) and only if this fails it will try to compute it using the new tactic.

coq/Frontend.v Outdated
Comment on lines 151 to 153
vm_compute (arg);
vm_compute (ret);
vm_compute (body)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even using vm_compute here turns out to be too aggressive in certain situations;

Working on a patch... probably fixed in a couple of minutes

@maxkurze1
Copy link
Author

Now the tactic uses cbn instead of vm_compute which should be conservative enough

@maxkurze1
Copy link
Author

maxkurze1 commented Aug 24, 2024

There is still some work to do here.
At the moment, I am able to construct a proof that the type checking succeeds. However, this proof term is massive, and it is part of the resulting term which bloats all following proofs and makes it hard to work with the action.

It would be nice to abstract the proof term and only keep the fact that it exists.

@sertel
Copy link
Collaborator

sertel commented Sep 5, 2024

Please provide a hint database to register manual proofs.
Garvit actually has started to write some "machinery" for type-checking in a more modular way. That we can also contribute to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants